<template>
  <div class="cw-echarts-threetwo" :id="name"></div>
</template>

<script>
import echarts from "echarts";
export default {
  data() {
    return {
      name: "cw-threetwo"
    };
  },
  created() {
    this.$nextTick(function() {
      // 需要修改 twotwo
      this.drow(this.name);
    });
  },
  methods: {
    drow(id) {
      this.charts = echarts.init(document.getElementById(id));
      this.charts.setOption({
        title: {
          text: "公司利润统计",
          x: "center",
          y: "top",
           textStyle: {
            color: "rgb(255, 255, 255)",
            fontSize: 18
          }
        },
        tooltip: {
          trigger: "axis"
        },
        legend: {
          data: ["葡萄酒", "桃汁", "苹果汁", "草莓酒", "花生油", "面粉"],
          y: "bottom",
          textStyle: {
            color: "rgb(255, 255, 255)",
            fontSize: 13
          },
          itemWidth: 14,
          padding: 1,
          itemHeight: 8
        },
        toolbox: {
          show: false,
          feature: {
            mark: {
              show: false
            },
            dataView: {
              show: false,
              readOnly: true
            },
            magicType: {
              show: false,
              type: ["line", "bar"]
            },
            restore: {
              show: false
            },
            saveAsImage: {
              show: false
            }
          }
        },
        calculable: true,
        xAxis: [
          {
            type: "category",
            boundaryGap: true,
            data: ["第一季度", "第二季度", "第三季度", "第四季度"],
            nameTextStyle: {
              fontSize: 14
            },
            splitLine: {
              show: false
            },
            splitArea: {
              show: false
            },
            axisLabel: {
              textStyle: {
                fontSize: 13,
                color: "white"
              }
            }
          }
        ],
        yAxis: [
          {
            type: "value",
            nameTextStyle: {
              fontSize: 10
            },
            min: 0,
            max: 10,
            boundaryGap: true,
            splitNumber: 10,
            axisLabel: {
              textStyle: {
                fontSize: 10,
                color: "rgb(255, 255, 255)"
              }
            }
          }
        ],
        series: [
          {
            name: "葡萄酒",
            type: "line",
            data: [2, 1, 5, 3]
          },
          {
            name: "桃汁",
            type: "line",
            data: [2.2, 4.3, 1.5, 2.9]
          },
          {
            type: "line",
            name: "苹果汁",
            data: [8, 6, 1, 9]
          },
          {
            type: "line",
            name: "草莓酒",
            data: [3, 6, 7, 2]
          },
          {
            type: "line",
            name: "花生油",
            data: [4.2, 2.7, 3, 4.6]
          },
          {
            type: "line",
            name: "面粉",
            data: [8, 6, 1, 9]
          }
        ],
        grid: {
          y: 70,
          height: 230
        }
      });
    }
  }
};
</script>

<style lang="scss">
// 需要修改 .xz-echarts-xx
.cw-echarts-threetwo {
  height: 380px;
  width: 100%;
}
</style>
